//
//  XMGTabBarController.m
//  01-百思不得姐
//
//  Created by xiaomage on 15/7/22.
//  Copyright (c) 2015年 小码哥. All rights reserved.
//

#import "XMGTabBarController.h"
#import "WYCNavigationController.h"
#import "WYCMeController.h"
#import "WYCBillController.h"
#import "WYCSummaryController.h"
#import "WYCRepaymentController.h"
#import "ADTabBar.h"
#import "UIColor+ColorHelper.h"
#import "ADAnimationView.h"
#import "WYCMainHomeController.h"

@interface XMGTabBarController ()

@end

@implementation XMGTabBarController
@synthesize button;



- (void)viewDidLoad
{
    [super viewDidLoad];
    [super viewDidLoad];
    
    [UINavigationBar appearance];
    
    // 通过appearance统一设置所有UITabBarItem的文字属性
    // 后面带有UI_APPEARANCE_SELECTOR的方法, 都可以通过appearance对象来统一设置
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectedAttrs[NSForegroundColorAttributeName] = WYCRGBColor(239, 177, 22);
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    
    
    [self setupChildVc:[[WYCMainHomeController alloc] init] title:@"首页" image:@"home_nomorl" selectedImage:@"home_select"];
    
    [self setupChildVc:[[WYCSummaryController alloc] init] title:@"汇总" image:@"TaBbar_summary_nomor" selectedImage:@"TaBbar_summary_select"];
    
    [self setupChildVc:[[WYCMeController alloc] init] title:@"我的" image:@"Me_Tabbar_nomor" selectedImage:@"Me_Tabbar_Select"];
    
    
    
}
/**
 * 初始化子控制器
 */
- (void)setupChildVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    // 设置文字和图片
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    // 包装一个导航控制器, 添加导航控制器为tabbarcontroller的子控制器
    WYCNavigationController *nav = [[WYCNavigationController alloc] initWithRootViewController:vc];
    nav.navigationBar.barTintColor = [UIColor whiteColor];
    
    [self addChildViewController:nav];
}
@end
